package qrcode.create_and_decode;

import cn.hutool.extra.qrcode.QrCodeUtil;
import com.google.zxing.qrcode.QRCodeReader;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;


public class Decoder extends QRCodeReader {

    File file = null;
    BufferedImage bufferedImage = null;
    String result = null;

    public static void main(String[] args) {
        String data = new Decoder().decoder("d:/test.png");
        System.out.println(data);
    }

    public String decoder(String imgPath) {
        file = new File(imgPath);

        try {
            bufferedImage = ImageIO.read(file);
            result = QrCodeUtil.decode(bufferedImage);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return result;
    }

}
